from selenium import webdriver
import time


bro = webdriver.Chrome(executable_path='./chromedriver')
bro.get('https://www.taobao.com/')

#定位搜索框，输入信息
search_input = bro.find_element_by_xpath('//*[@id="q"]')
search_input.send_keys('iphone')

#点击搜索按钮
btn = bro.find_element_by_css_selector('.btn-search')
btn.click()

# 加载新页面  回退，前进
bro.get('https://baidu.com')
bro.back()
bro.forward()

time.sleep(2)
bro.quit()